<?php

namespace App\Http\Middleware;

use Closure;
use Illuminate\Support\Facades\Route;
use Spatie\Permission\Models\Permission;

class CheckPermission
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
     */
    public function handle($request, Closure $next)
    {
        // $permission = Permission::query()->where('name', Route::currentRouteName())->first();
        // if(!$permission){
        //     if(Route::currentRouteName()){
        //         Permission::create(['name' => Route::currentRouteName()]);
        //     }
        // }
        
        return $next($request);
    }
}
